@extends('layouts.console_header')

@section('title', '新增商家')

@section('resources')
    @parent
    <!-- css 文件 -->
    <link rel="stylesheet" href="{{env('CSS_DOMAIN')}}css/check_pc.css?v={{env('CCS_VERSION')}}">
    <link rel="stylesheet" href="{{env('CSS_DOMAIN')}}css/kalendae1.css?v={{env('CCS_VERSION')}}" type="text/css" charset="utf-8">
    <!-- <link rel="stylesheet" href="{{env('CSS_DOMAIN')}}/css/bootstrap.min.css?v={{env('CSS_VERSION')}}" /> -->
    <link rel="stylesheet" href="{{env('CSS_DOMAIN')}}css/style.css?v={{env('CSS_VERSION')}}" />
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
    <style type="text/css" media="screen">
	    .kalendae .k-days span.closed {background:red;}
	    .btn-primary{margin-left: 60px;}
	    .pictureshow{margin-left: 10px;overflow: hidden;}
	    #container{width: 870px;height: 400px;position: relative;}
	    #shop_type{width: 70px;height: 25px;border: 1px solid #000;float: left;margin-top: 5px;}
	    .shop_name{padding-left: 7px;}
	    .k-out-of-month{opacity: 0;}
	    #choose_time{position: absolute;top: 0;right: 10px;width: 100px;height: 30px;text-align: center;line-height: 30px;border: 1px solid #9955c6;color: #9955c6;cursor: pointer;z-index: 9;}
    </style>
@endsection

@section('content')
<!--  html内容  -->
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;"><span style="color: #7f7f7f;">
		首页>商家版运营></span><span class="co_violet">新增商家</span></p>
		{{--<a onclick="history.go(-1);" href="#"><p class="fr tc back_btn">返回</p></a>--}}
	</div>
	<div class="new_shop_center">
		<div class="new_shop_top" style="padding: 0 80px;">
			<span class="fl show">①门店基本信息</span>
			<p class="fl">></p>
			<span class="fl">②门店图片上传</span>
			<p class="fl">></p>
			<span class="fl">③翻倍日与代付规则</span>
			<p class="fl">></p>
			<span class="fl">④收款账号与经营资质</span>
		</div>
		<form action="/console/shop/add" method="POST" id="shop_form">
		    <input type="hidden" name="cityid" value="{{$cityid}}" />
			<ul class="shop_details1">
				<li class="shopnextli">
					<p>
						<span class='shop_details1_name'>指定商务</span>
						@if(isset($businessPersonnel) &&!empty($businessPersonnel))
							@if($businessPersonnel['roletype'] == 1)
								<span  style="line-height: 35px;margin-left: 10px;width: 400px;">{{$businessPersonnel['roleinfo']['realname']}}&nbsp;&nbsp;&nbsp;&nbsp;{{$businessPersonnel['roleinfo']['mobile']}}</span>
								<input type="hidden" name="maintainerid" value="{{$businessPersonnel['roleinfo']['adminid']}}">
							@else
								<select class="select" name="" id="roleinfo" style="width: 180px; height: 35px;">
									<option value="0">请选择</option>
									@foreach($businessPersonnel['roleinfo'] as $list)
										<option value="{{$list['adminid']}}">{{$list['realname']}} {{$list['mobile']}}</option>
									@endforeach
								</select>
								<input type="hidden" name="maintainerid" id="adminroleid" value="">
							@endif
						@endif
					</p>
					<p>
						<span class='shop_details1_name'>门店名称</span>
						<input type="text" id="mendian" name="name" maxlength="20" value="" required="required"/>
						<span id="mendian_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
					</p>
					<p>
                        <span class='shop_details1_name'>门店编号</span>

                        <input type="text" id="code" name="code" value="" required="required" />
                        <span id="shop_details1_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
                    </p>
					<p>
						<span class='shop_details1_name'>前台电话</span>
						<input type="text" name="contactnumber" id="phonenum" value="" required="required" />
						<span id="phonenum_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
					</p>
					<p>
						<span class='shop_details1_name'>营业时间</span>
						<input type="text" name="businesshours" id="businesshours" value="" required="required" />
					</p>
					<p>
                        <span class='shop_details1_name'>接收短信手机</span>
                        <input type="text" name="smsphone" id="message_phonenum" value="" required="required" maxlength="11" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                        <span id="message_phonenum_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
                    </p>
					<div class="demo">
						<form action="" name="form1">
                            <lable style="width: 100px;float: left;">所在地</lable>
                            <span id="province" style="float: left;margin-right: 10px;">
                                <select class="select" name="shopprovinceid" style="height:40px;" onchange="showCity(this)">

                                </select>
                            </span>
                            <span id="city" style="float: left;margin-right: 10px;">
                                <select class="select" name="shopcityid" style="height:40px;"  onchange="showDistrict(this)">
                                    {{--<option value="">--请选择城市--</option>--}}
                                    <option value="{{$cityid}}" selected="selected">{{$cityname}}</option>
                                </select>
                                <input type="hidden" name="shopcityname" value="{{$cityname}}" />
                            </span>
                            <span id="district" style="float: left;margin-right: 10px;">
                                <select class="select" name="shopdistrictid" style="height:40px;" onchange="showBusinessArea(this)">
                                    <option value="">--请选择区县--</option>
                                @foreach($districtlists as $districtlist)
                                    <option value="{{$districtlist['id']}}">{{$districtlist['name']}}</option>
                                @endforeach
                                </select>
                                <input type="hidden" name="shopdistrictname" value="" />
                            </span>
                            <span id="businessarea" style="float: left;">
                                <select class="select" name="shopbusinessareaid" style="height:40px;" onchange="selectBusinessArea(this)">
                                    <option value="0">--请选择商圈--</option>
                                </select>
                                <input type="hidden" name="shopbusinessareaname" value="" />
                            </span>
						</form> 
					</div>
					<div style="clear: both;"></div>
					<p>
						<span class='shop_details1_name'>门店地址</span>
						<input type="text" name="address" id="shop_address" maxlength="30" value="">
						<span id="shop_address_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
					</p>
					<p>
						<span class='shop_details1_name'>经纬度</span>
						<input style="width: 100px;height: 30px;border-radius: 5px; margin-top: 4px;" type="button" name="" value="获取经纬度" onclick="getLngAndlat()" />
						<!-- <input style="width: 100px;height: 30px;border-radius: 5px; margin-top: 4px;margin-left: 570px;" type="button" name="" value="保存" id="preserve" /> -->
					    <input type="hidden" id="longitude" name="longitude" value="" placeholder="经度"/>
						<input type="hidden" id="latitude" name="latitude" value="" placeholder="纬度"/>
					</p>
					<!-- <input style="width: 200px;height: 35px;border: 1px solid #ccc;margin: 10px 20px;" type="text" placeholder="请输入关键字进行搜索" id="tipinput"> -->
					<!-- <input style="width: 200px;height: 35px;border: 1px solid #ccc;margin: 10px 20px;" type="text" readonly="true" id="lnglat"> -->
					<div id="container"></div>
					<p>
						<span class='shop_details1_name'>经营分类</span>
						<span id="firstclass" style="width: 175px;">
                            <select class="select" name="firstclassid" style="height:40px; width: 160px" onchange="selectclass('first',this)">
                                <option value="0">--请选择一级分类--</option>
                                <option value="1">美食</option>
                                <option value="2">休闲娱乐</option>
                                <option value="3">生活服务</option>
                                <option value="4">酒店</option>
                                {{--<option value="5">旅游</option>--}}
                            </select>
                            <input type="hidden" name="firstclassname" value=""/>
                        </span>
                        <span id="secondclass" style="width:175px;">
                            <select class="select" name="secondclassid" style="height:40px; width: 160px" onchange="selectclass('second',this)">
                                <option value="0">--请选择二级分类--</option>
                            </select>
                            <input type="hidden" name="secondclassname" value="" />
                        </span>
					</p>
					<p>
						<span>商家标签</span>
						<input type="text" id="label" name="label" maxlength="8" value="" placeholder="选填，限八个字以内">
						<span id="label_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
					</p>
					<p>
						<span>商家简介</span>
						<textarea name="description" id="description" maxlength="200" cols="30" rows="10"></textarea>
						<span id="description_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
					</p>

					<p style="width: 850px;" class="oh">
						<span class="next_step1" style="width: 170px;height: 35px;border-radius: 5px;float: right;border: 1px solid #000;text-align: center;line-height: 35px;cursor: pointer;">下一步</span>
					</p>
				</li>
				<li class="shopnextli" hidden>
					<div class="form-group jingyzz oh">
                        <label class="fl" style="width: 200px;text-align: center;">商家主图</label>
                        <div class="oh fl pic_box_outer" style="margin-left: 0px;">
							<input type="file"  id="logo" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('logoid','logo','logo',client,'logo','input[name="logo"]','.progress'); />
							<span class="upload_pic fl">+上传门头照片<br>（作为商家主图）</span>
							<div class="fl pictureshow" id="logoid"></div>
						</div>
                    </div>
                    <div class="progress"></div>
                    <input type="hidden" name="logo" value="" />

                    <div class="shop_check_picture oh">
	                    <span class="fl">环组境图<br>(必填，最少3张，最多可19张)</span>
	                    <div class="form-group jingyzz oh">
	                        <div class="oh fl pic_box_outer" style="margin-left: 0px;">
	                            <input type="file"  id="logo_pic" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviewsPhoto('logo_picid','logo_pic','photospath',client,'logo_pic',"input[name='photospath']","input[name='photoscount']"); />
	                            <span class="upload_pic fl">+上传环境组图</span>
	                            <div class="fl pictureshow" id="logo_picid"></div>
	                        </div>

	                    </div>
	                    <div class="progress_more"></div>
	                    <input type="hidden" name="photospath" value="" />
	                    <input type="hidden" name="photoscount" value="" />
	                </div>

	                <div class="oh ">
	                    <h3 class="fl">商品图(必填，最少3件商品，最多可20件商品)</h3>
	                </div>
	                <ol class="shop_addnew_details fz_14">
	                    <li>
                            <input type="hidden" name="goodsindex" value="1">

	                        <div class="oh shop_addnew_details_title"><h4 style="font-weight: normal;" class="fz_16 fl">商品1</h4><!-- <span class="fr fz_16 co_red shop_delete">删除</span> --></div>
	                        <p>
	                            <span>商品名称</span>
	                            <input class="shop_name" type="text" name="goodsname1" value="" placeholder="15字以内">
	                        </p>
	                        <p>
	                            <span style="position: relative;top: -70px;">商品介绍(选填)</span>
	                            <textarea name="goodsdescription1" id="" cols="30" rows="10" placeholder="可不填，100字以内"></textarea>
	                        </p>
	                        <div class="form-group jingyzz oh">
	                            <label class="fl" style="width: 100px;">商品图</label>
	                            <div class="oh fl pic_box_outer" style="margin-left: 0px;">
	                                <input type="file"  id="logo1" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('logoid1','logo1','goodsphoto1',client,'logo1',"input[name='goodsphoto1']",'.progress1'); />
	                                <span class="upload_pic fl">+上传商品图</span>
	                                <div class="fl pictureshow" id="logoid1"></div>
	                            </div>
	                        </div>
	                        <div class="progress1">
	                        
	                        </div>
	                        <input type="hidden" name="goodsphoto1" value="" />
	                    </li>
	                    <li>
                            <input type="hidden" name="goodsindex" value="2">

	                        <div class="oh shop_addnew_details_title"><h4 style="font-weight: normal;" class="fz_16 fl">商品2</h4><!-- <span class="fr fz_16 co_red shop_delete">删除</span> --></div>
	                        <p>
	                            <span>商品名称</span>
	                            <input class="shop_name" type="text" name="goodsname2" value="" placeholder="15字以内">
	                        </p>
	                        <p>
	                            <span style="position: relative;top: -70px;">商品介绍(选填)</span>
	                            <textarea name="goodsdescription2" id="" cols="30" rows="10" placeholder="可不填，100字以内"></textarea>
	                        </p>
	                        <div class="form-group jingyzz oh">
	                            <label class="fl" style="width: 100px;">商品图</label>
	                            <div class="oh fl pic_box_outer" style="margin-left: 0px;">
	                                <input type="file"  id="logo2" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('logoid2','logo2','goodsphoto2',client,'logo2',"input[name='goodsphoto2']",'.progress2'); />
	                                <span class="upload_pic fl">+上传商品图</span>
	                                <div class="fl pictureshow" id="logoid2"></div>
	                            </div>
	                        </div>
	                        <div class="progress2">
	                        
	                        </div>
	                        <input type="hidden" name="goodsphoto2" value="" />
	                    </li>
	                    <li>
                            <input type="hidden" name="goodsindex" value="3">

	                        <div class="oh shop_addnew_details_title"><h4 style="font-weight: normal;" class="fz_16 fl">商品3</h4><!-- <span class="fr fz_16 co_red shop_delete">删除</span> --></div>
	                        <p>
	                            <span>商品名称</span>
	                            <input class="shop_name" type="text" name="goodsname3" value="" placeholder="15字以内">
	                        </p>
	                        <p>
	                            <span style="position: relative;top: -70px;">商品介绍(选填)</span>
	                            <textarea name="goodsdescription3" id="" cols="30" rows="10" placeholder="可不填，100字以内"></textarea>
	                        </p>
	                        <div class="form-group jingyzz oh">
	                            <label class="fl" style="width: 100px;">商品图</label>
	                            <div class="oh fl pic_box_outer" style="margin-left: 0px;">
	                                <input type="file"  id="logo3" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('logoid3','logo3','goodsphoto3',client,'logo3',"input[name='goodsphoto3']",'.progress3'); />
	                                <span class="upload_pic fl">+上传商品图</span>
	                                <div class="fl pictureshow" id="logoid3"></div>
	                            </div>
	                        </div>
	                        <div class="progress3">
	                        
	                        </div>
	                        <input type="hidden" name="goodsphoto3" value="" />
	                    </li>
	                </ol>
	                <p class="shop_addnew co_violet" style="margin-top: 20px;height: 50px;line-height: 50px;">+新增商品</p>
	                <input type="hidden" name="goods" value="" >
					<p style="width: 1100px;margin-top: 30px;" class="oh">
						<span class="last_step_pic" style="width: 170px;height: 35px;border-radius: 5px;float: left;border: 1px solid #000;text-align: center;line-height: 35px;cursor: pointer;">上一步</span>
						<span class="next_step_pic" style="width: 170px;height: 35px;border-radius: 5px;float: right;border: 1px solid #000;text-align: center;line-height: 35px;cursor: pointer;">下一步</span>
					</p>
				</li>
				<li class="shopnextli" hidden>
					<div>
						<h2 class="fz_18">翻倍日</h2>
						<p class="doubleday_set weekday_set">
							<span style="margin-right: 10px;margin-top: 4px;">每周翻倍日上限</span>
							<span class="weekdoubleday">
							    <select class="select" name="weekdoubleday" style="height:30px;width: 50px;">
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7" selected="selected">7</option>
                                </select>
                            </span>
							<span style="margin-left: 10px;margin-top: 4px;">天</span>
						</p>
						<div id="double_date" style="margin: 10px 0;position: relative;height: 100px;">
							<p id="choose_time">选择日期</p>
		                    <!-- <div style="border: 1px solid #000;width: 1025px;min-height: 21px;" id="choose1"></div> -->
		                    <input name="event" style="border: 1px solid #000;width: 1200px;height: 80px;position: absolute;left: 0;opacity: 0;cursor: pointer;z-index: 10;" type="text" value="" id="choose" onchange="change()">
		                    <textarea  style="border: 1px solid #000;width: 1025px;height: 70px;position: absolute;top: 0;left: 0;z-index: 11;" name="" id="choose1" cols="30" rows="10"></textarea>
						</div>
						<div class="shop_doubleday" hidden>
							<span class="doubleday_set">翻倍日期备注:</span>
							<input type="text" name="remark" value="" style="outline:#000; border:1px solid black;height:30px;width:500px;border-radius:5px;">
						</div>
					</div>
					<div>
						<h2 class="fz_18">代付规则</h2>
						<p class="doubleday_set today_consume">
							<span style="margin-right: 10px;margin-top: 4px;">当日消费次数</span>
							<span class="buynumber">
							    <select class="select" name="buynumber" style="height:30px;width: 50px;">
							        <option value="0" selected="selected">不限</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                </select>
							</span>
							<span style="margin-left: 10px;margin-top: 4px;">次/用户</span>
						</p>
						<div style="position: relative;overflow: hidden;height: 60px;">
							<span style="margin-top: 20px;" class="fl">封顶金额</span>
							<div class="slideThree" style="position: absolute;top: 0px;left: 100px;">
				                <input type="checkbox" value="1"  id="slideThree" name="" checked />
				                <label for="slideThree"></label>
				            </div>
						</div>
						<p class="fending" style="display: none;"><input class="fz_16" style="width: 150px;height: 30px;border: 1px solid #000;margin: 0 10px 0 100px;padding-left: 10px;" type="text" id="maxsales" name="maxsales" value="" placeholder="请输入≥300的数字"><span>元封顶</span></p>
						<div style="position: relative;overflow: hidden;height: 60px;">
							<span style="margin-top: 20px;" class="fl">全场参与</span>
							<div class="slideOne">  
							    <input type="checkbox" value="" id="slideOne" name="allconsume" checked />
							    <label for="slideOne"></label>
							</div>
						</div>
						<p class="allin" style="display: none;"><span style="margin-left: 100px;margin-top: 10px;">全场参与，除</span><input class="fz_16" style="width: 500px;height: 30px;border: 1px solid #000;padding-left: 10px;margin: 10px;" type="text" id="notpartakegoods" name="notpartakegoods" value="" placeholder="请输入不参与的内容"><span>不参与</span></p>
						<p class="oh rules_bottom">
							<span class="fl">发票</span>
							<input class="fl" type="text" name="invoice" value="与商家沟通">
						</p>
						<p class="oh rules_bottom">
							<span class="fl">其他</span>
							<select name="" id="shop_type" onchange="typechack(this)">
		                        <option value="empty">请选择</option>
		                        <option value="hotel">酒店</option>
		                        <option value="restuarant">餐饮</option>
		                        <option value="drink">饮料店</option>
		                        <option value="clothing">服装店</option>
		                        <option value="flower">花店</option>
		                        <option value="bar">酒吧</option>
		                        <option value="ktv">KTV</option>
		                    </select>
							<textarea class="fl" name="other" maxlength="50" id="other" cols="30" rows="10"></textarea>
							<span id="other_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
						</p>
						<p class="oh rules_bottom">
							<span class="fl">温馨提示</span>
							<textarea class="rule_forsalf fl fz_13" name="tips">为避免商品价格不实，翻贝网平台不显示商家价格，以用户和实体店最终议价为准，最后通过翻贝网代付。翻贝网热线：400-6989-820</textarea>
						</p>
						<p style="width: 850px;" class="oh">
							<span class="last_step1" style="width: 170px;height: 35px;border-radius: 5px;float: left;border: 1px solid #000;text-align: center;line-height: 35px;cursor: pointer;">上一步</span>
							<span class="next_step2" style="width: 170px;height: 35px;border-radius: 5px;float: right;border: 1px solid #000;text-align: center;line-height: 35px;cursor: pointer;">下一步</span>
						</p>
					</div>
				</li>
				<li class="shopnextli" hidden>
					<div>
						<h2 class="fz_18">收款账户</h2>
						<p class="oh">
							<span class="fl">持卡人</span>
							<input class="fl" type="text" id="cardholder" name="cardholder" value="" required="required">
							<span id="cardholder_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
						</p>
						<p class="oh">
							<span class="fl">身份证号</span>
							<input class="fl" type="text" id="idcard" maxlength="18" name="idcard" value="" required="required">
							<span id="idcard_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
						</p>
						<p class="oh">
							<span class="fl">银行账号</span>
							<input class="fl" type="text" id="bankcard" name="bankcard" value="" required="required">
							<span id="bankcard_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
						</p>
						<p class="oh">
							<span class="fl">银行名称</span>
							<input style="width: 100px;height: 30px;border-radius: 5px;" type="button" name="" value="查询" onclick="getbankname()" />
						</p>
						<p class="oh">
							<span class="fl">银行名称</span>
							<input type="text" name="bankname" id="bankname" value="" placeholder="请输入开户行支行名称">
							<span id="bankname_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
						</p>
						<p class="oh">
                            <span class="fl">开户支行</span>
                            <select name="bankprovince" id="bankprovince"  onchange="showBankCity(this)">
                                <option value="">--请选择省份--</option>
                            </select>
                            <select name="bankcity" id="bankcity">
                                <option value="">--请选择城市--</option>
                            </select>
                            <input style="width: 402px;" type="text" id="opencardbank" name="opencardbank" value="" placeholder="请填入支行名称">
                            <span id="opencardbank_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
                        </p>
					</div>
					<div>
						<h2 class="fz_18">法人/门店负责人信息</h2>
						<p class="oh">
							<span class="fl">负责人姓名</span>
							<input class="fl" type="text" id="parentname" name="parentname" value="" required="required">
							<span id="parentname_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
						</p>
						<p class="oh">
							<span class="fl">商家登录帐号</span>
							<input class="fl" maxlength="11" type="text" id="parentmobile" name="parentmobile" value="" required="required" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
							<span id="parentmobile_message" style="line-height: 35px;margin-left: 10px;width: 150px;"></span>
						</p>
						<p class="oh">
                            <span class="fl">合同签约开始时间</span>
                            <input class="fl" type="date" id="contractstarttime" name="contractstarttime" value="{{date('Y-m-d', strtotime('+1day'))}}" required="required" readonly>
                        </p>
                        <p class="oh">
                            <span class="fl">合同签约结束时间</span>
                            <input class="fl" type="date" id="contractendtime" name="contractendtime" value="" required="required">
                        </p>
					</div>
					<div class="jingyzz">
						<h2 class="fz_18">经营资质</h2>
						<div class="oh">
							<div class="oh form-group pic_box_outer">
								<input type="file" id="bankcardphoto" multiple="multiple" value="" onchange=javascript:setImagePreviews('bankcardphotoid','bankcardphoto','bankcardphoto',client,'bankcardphoto','input[name="bankcardphoto"]','.progress_bankcar'); />
								<span class="upload_pic fl">+上传收款账号的银行卡正面照</span>
								<div class="fl pictureshow" id="bankcardphotoid"></div>
								<span class="fz_14" style="position: absolute;top: 103px;left: 20px;width: 220px;">上传说明：图片不能反光 文字清晰</span>
							</div>
							<div class="progress_bankcar">
		                        
		                    </div>
                            <input type="hidden" name="bankcardphoto" value="" />
						</div>
						<p class="oh">
                            <div class="oh form-group pic_box_outer">
								<input type="file" id="licensephoto" multiple="multiple" value="" onchange=javascript:setImagePreviews('licensephotoid','licensephoto','licensephoto',client,'licensephoto','input[name="licensephoto"]','.progress_license'); />
								<span class="upload_pic fl">+上传营业执照</span>
								<div class="fl pictureshow" id="licensephotoid"></div>
								<span class="fz_14" style="position: absolute;top: 103px;left: 20px;width: 220px;">上传说明：图片不能反光 文字清晰</span>
							</div>
							<div class="progress_license">
		                        
		                    </div>
                            <input type="hidden" name="licensephoto" value=""/>
						</p>
						<p class="oh">
                            <div class="oh form-group pic_box_outer">
                                <input type="file" id="idcardfrontphoto" multiple="multiple" value="" onchange=javascript:setImagePreviews('idcardfrontphotoid','idcardfrontphoto','idcardfrontphoto',client,'idcardfrontphoto','input[name="idcardfrontphoto"]','.progress_idcardfront'); />
                                <span class="upload_pic fl">+上传法人/门店负责人的身份证正面照</span>
                                <div class="fl pictureshow" id="idcardfrontphotoid"></div>
                                <span class="fz_14" style="position: absolute;top: 103px;left: 20px;width: 220px;">上传说明：图片不能反光 文字清晰</span>
                            </div>
                            <div class="progress_idcardfront">
		                    </div>
                            <input type="hidden" name="idcardfrontphoto" value="" />
                        </p>
						<p class="oh">
						    <div class="oh form-group pic_box_outer">
								<input type="file" id="idcardbackphoto" multiple="multiple" value="" onchange=javascript:setImagePreviews('idcardbackphotoid','idcardbackphoto','idcardbackphoto',client,'idcardbackphoto','input[name="idcardbackphoto"]','.progress_idcardback'); />
								<span class="upload_pic fl">+上传法人/门店负责人的身份证反面照</span>
								<div class="fl pictureshow" id="idcardbackphotoid"></div>
								<span class="fz_14" style="position: absolute;top: 103px;left: 20px;width: 220px;">上传说明：图片不能反光 文字清晰</span>
							</div>
							<div class="progress_idcardback">
		                    </div>
                            <input type="hidden" name="idcardbackphoto" value="" />
						</p>
					</div>
					<p style="width: 850px;" class="oh">
						<span class="last_step2" style="width: 170px;height: 35px;border-radius: 5px;float: left;border: 1px solid #000;text-align: center;line-height: 35px;cursor: pointer;">上一步</span>
						<input type="button" style="width: 170px;height: 35px;border-radius: 5px;float: right;border: 1px solid #000;text-align: center;line-height: 35px;background-color: #9955c6;cursor: pointer;color: #fff;" id="complete" value="完成">
					</p>
				</li>
			</ul>
		</form>
	</div>
</section>
@endsection

@section('scriptResources')
    @parent
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.3&key=a9fe1b184bacd00ecd70365903024419&plugin=AMap.Autocomplete"></script>
    <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
    <script src="{{env('JS_DOMAIN')}}js/kalendae.standalone1.js?v={{env('JS_VERSION')}}" type="text/javascript" charset="utf-8"></script>
    {{--<script src="https://www.promisejs.org/polyfills/promise-6.1.0.js"></script>--}}
    <script src="{{env('JS_DOMAIN')}}js/promise-6.1.0.js"></script> <!--放到本地-->
    <script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-4.3.0.min.js"></script>
    <script>
        'use strict';
        var OSS = OSS.Wrapper;
        var STS = OSS.STS;
        var client = new OSS({
            region: 'oss-cn-beijing',
            accessKeyId: '{{$AccessKeyId}}',
            accessKeySecret: '{{$AccessKeySecret}}',
            stsToken: '{{$SecurityToken}}',
            bucket: 'fbw',
            secure: true
        });
        var adminUserId = '{{$adminUserId}}';
        var cityid='{{$cityid}}';
        var cityname='{{$cityname}}';
        var provinceid='{{$provinceid}}';
        var provincename='{{$provincename}}';

        //获取经纬度
        var lnglatXY;
    	var marker,map = new AMap.Map("container", {
	        resizeEnable: true,
	        zoom: 13
	    });
		getCityLngAndlat();
		function getCityLngAndlat() {
			var address = $("select[name='shopcityid']").find("option:selected").html();
			if(address == '') {
				alert("请输入地址");
			}
			$.ajax({
				url : '/console/lngandlat/get',
				data:{"address":address},
				dataType:'json',
				success:function(data){
					if(data.status == 'success') {
						var longitude = data.data.longitude;
						var latitude = data.data.latitude;
						$("input[name='longitude']").val(longitude);
						$("input[name='latitude']").val(latitude);
						lnglatXY = [$("input[name='longitude']").val(),$("input[name='latitude']").val()]; //已知点坐标
						if (marker) {
							marker.setMap(null);
							marker = null;
						}
						marker = new AMap.Marker({  //加点
							map: map,
							position: lnglatXY
						});
						map.setFitView();
						// }
						function geocoder_CallBack(data) {
							var address = data.regeocode.formattedAddress; //返回地址描述
							document.getElementById("result").innerHTML = address;
						}
						//为地图注册click事件获取鼠标点击出的经纬度坐标
						var clickEventListener = map.on('click', function(e) {
							marker.setMap(null);
							lnglatXY=[e.lnglat.getLng(),e.lnglat.getLat()]
							// document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat();
							marker = new AMap.Marker({  //加点
								map: map,
								position: lnglatXY
							});
							map.setFitView();
						});
						// $("#preserve").click(function(){
						// 	$("#longitude").val(lnglatXY[0]);
						// 	$("#latitude").val(lnglatXY[1]);
						// 	alert("保存成功");
						// })
						function select(e) {
							if (e.poi && e.poi.location) {
								map.setZoom(15);
								map.setCenter(e.poi.location);
							}
						}
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert(XMLHttpRequest.status);
					alert(XMLHttpRequest.readyState);
					alert(textStatus);
				}
			});
		}
        function getLngAndlat() {
        	if($("select[name='shopdistrictid']").val() == ''){
        		alert("门店地址请选择到区县！！！");
        		return;
        	}
             var address = $("select[name='shopcityid']").find("option:selected").html() + $("select[name='shopdistrictid']").find("option:selected").html() + $("input[name='address']").val();
             if(address == '') {
                 alert("请输入地址");
             }
             $.ajax({
                 url : '/console/lngandlat/get',
                 data:{"address":address},
                 dataType:'json',
                 success:function(data){
                    if(data.status == 'success') {
                        var longitude = data.data.longitude;
                        var latitude = data.data.latitude;
                        $("input[name='longitude']").val(longitude);
                        $("input[name='latitude']").val(latitude);
						lnglatXY = [$("input[name='longitude']").val(),$("input[name='latitude']").val()]; //已知点坐标
						if (marker) {
				            marker.setMap(null);
				            marker = null;
				        }     
				        marker = new AMap.Marker({  //加点
				            map: map,
				            position: lnglatXY
				        });
				        map.setFitView();
					    // }
					    function geocoder_CallBack(data) {
					        var address = data.regeocode.formattedAddress; //返回地址描述
					        document.getElementById("result").innerHTML = address;
					    }
					    //为地图注册click事件获取鼠标点击出的经纬度坐标
					    var clickEventListener = map.on('click', function(e) {
					    	marker.setMap(null);
					    	lnglatXY=[e.lnglat.getLng(),e.lnglat.getLat()]
					        // document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat();
					        marker = new AMap.Marker({  //加点
					            map: map,
					            position: lnglatXY
					        });
					        map.setFitView();
					    });
					    // $("#preserve").click(function(){
					    // 	$("#longitude").val(lnglatXY[0]);
					    // 	$("#latitude").val(lnglatXY[1]);
					    // 	alert("保存成功");
					    // })
					    function select(e) {
					        if (e.poi && e.poi.location) {
					            map.setZoom(15);
					            map.setCenter(e.poi.location);
					        }
						}
	                }
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
             });
	        }
	    //其他选择的内容
	    function typechack(id){
            if($(id).val() == "empty"){
                $("#other").val("");
            }
            if($(id).val() == "hotel"){
                $("#other").val("每个ID仅限代付1间房；特价房、钟点房均可使用翻贝网代付；");
            }
            if($(id).val() == "restuarant"){
                $("#other").val("每桌仅限1位用户代付；茶位费、餐位费、主食均可使用翻贝网代付；");
            }
            if($(id).val() == "drink"){
                $("#other").val("饮品类每个ID仅限代付2杯；其他不限；");
            }
            if($(id).val() == "clothing"){
                $("#other").val("每个ID仅限代付1件；");
            }
            if($(id).val() == "flower"){
                $("#other").val("每个ID仅限代付1束；");
            }
            if($(id).val() == "bar"){
                $("#other").val("无代付封顶限制，所有店内消费均可使用使用翻贝网代付；");
            }
            if($(id).val() == "ktv"){
                $("#other").val("自选超市（零食、酒水、饮料）消费均可使用翻贝网代付；");
            }
        }
        //判断商家编码是否可用
	    $('#code').blur(function(){
	        var code = $("input[name='code']").val();
	        if(code == ""){
	        	$("#shop_details1_message").html("内容不能为空！");
	        	$("#shop_details1_message").css({"color":"red"});
	        }else{
	        	$.ajax({
		    		url : '/console/shop/code/verify',
		    		data:{shopcode:code},
		    		dataType:'json',
		    		type:'get',
		    		success:function (data) {
		    			if(data.status == 'success') {
	                        $("#shop_details1_message").html("可用");
	                        $("#shop_details1_message").css({"color":"green"});
		    			} else {
		    			    $("#shop_details1_message").html("重复，不可用");
	                        $("#shop_details1_message").css({"color":"red"});
		    				$('#code').focus()
		    			}
		    		},
		    		error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
		    	});
	        }
	    })
        //各个输入框聚焦触发事件
        var timer;
	    function iptfocus(id,spanid,num){
	    	$(id).focus(function(){
	    		 timer=setInterval(function(){
		    		var iptlen=$(id).val().length;
		    		var bump=num-iptlen;
		    		if(bump >= 0){
		    			$(spanid).html("还可以输入"+bump+"字");
		    			$(spanid).css({"color":"green"});
		    		}
		    	},1)
	    	})
	    	$(id).blur(function(){
	    		clearInterval(timer);
	    	})
	    }
	    iptfocus("#mendian","#mendian_message",20);
	    iptfocus("#shop_address","#shop_address_message",30);
	    iptfocus("#label","#label_message",8);
	    iptfocus("#description","#description_message",200);
	    iptfocus("#other","#other_message",50);
	    function iptblur(id,spanid){
	    	$(id).blur(function(){
	    		var iptval=$(id).val();
		    	if(iptval == ""){
		    		$(spanid).html("内容不能为空！");
		    		$(spanid).css({"color":"red"});
		    	}else{
		    		$(spanid).html("");
		    		$(spanid).css({"color":"green"});
		    	}
	    	})    //各个输入框失去焦点触发事件
	    }
	    iptblur("#mendian","#mendian_message");
	    iptblur("#phonenum","#phonenum_message");
	    iptblur("#message_phonenum","#message_phonenum_message");
	    iptblur("#shop_address","#shop_address_message");
	    // iptblur("#label","#label_message");
	    // iptblur("#description","#description_message");
	    iptblur("#cardholder","#cardholder_message");

	    iptblur("#bankcard","#bankcard_message");
	    iptblur("#bankname","#bankname_message");
	    iptblur("#opencardbank","#opencardbank_message");
	    iptblur("#parentname","#parentname_message");
	    iptblur("#parentmobile","#parentmobile_message");
	    iptblur("#idcard","#idcard_message");
        //封顶金额、全场参与   开关
        $('.slideThree label').click(function(){
        	if($('.slideThree label').position().left==0){//开关打开
        		$('.slideThree').css('background-color','#9955c6');
        		$('.fending').show();
        		$("#maxsales").val("300");
        	}else{//开关关闭
        		$('.slideThree').css('background-color','#cdcdcd');
        		$('.fending').hide();
        		$("#maxsales").val("0");
        	}
        })
        $("#maxsales").blur(function(){
        	if ($("#maxsales").val() < 300) {
        		alert("请填入>=300的数据")
        		$("#maxsales").focus();
        	};
        })
        $('.slideOne label').click(function(){
        	if($('.slideOne label').position().left==0){//开关打开
        		$('.slideOne').css('background-color','#9955c6');
        		$('.allin').hide();
        	}else{//开关关闭
        		$('.slideOne').css('background-color','#999');
        		$('.allin').show();
        	}
        })
		//将所得商务人员的信息赋值roleinfo
		//通过绑定change事件，当下拉框内容发生变化时事件被启动provincename
		$("#roleinfo").bind("change",function(){
			//获取自定义属性的值
			var bianhao = $(this).find("option:selected").attr("value");
			$("input[name='maintainerid']").val(bianhao);
		});

        $(document).ready(function(){
            $('.next_step1').click(function(){  //第一个下一步
				if($("#adminroleid").val() == ""){
					alert("商务人员不能为空");return;
				}else if($("#mendian").val() == ""){
            		alert("门店名称不能为空");return;
            	}else if($("#code").val() == ""){
            		alert("门店编号不能为空");return;
            	}else if($("#phonenum").val() == ""){
            		alert("前台电话不能为空");return;
            	}else if($("#message_phonenum").val().length < 11){
            		alert("请输入正确的接收短信手机号");return;
            	}else if($("#shop_address").val() == ""){
            		alert("门店地址不能为空");return;
            	}else if($("select[name='shopcityid']").val() == ''){
            		alert("所在地城市不能为空");return;
            	}else if($("select[name='shopdistrictid']").val() == ''){
            		alert("所在地区县不能为空");return;
            	}else if($("select[name='firstclassid']").val() == 0 || $("select[name='firstclassid']").val() == ''){
            		alert("经营分类一级分类不能为空");return;
            	}else if($("select[name='secondclassid']").val() == 0 || $("select[name='secondclassid']").val() == ''){
            		alert("经营分类二级分类不能为空");return;
            	}else{
            		$("#longitude").val(lnglatXY[0]);
					$("#latitude").val(lnglatXY[1]);
            		$('.shop_details1 .shopnextli').eq(0).hide();
	                $('.shop_details1 .shopnextli').eq(1).show();
	                $('.new_shop_top span').eq(1).addClass('show').siblings().removeClass('show');
            	}
            })
            $('.next_step_pic').click(function(){  //第二个下一步
            	if($("input[name='logo']").val() == ""){
            		alert("商家主图不能为空");return;
            	}else if($("input[name='photoscount']").val() == ""){
            		alert("环组境图不能为空");return;
            	}else if(($('.shop_addnew_details li').length) < 3){
            		alert("商品图至少要上传3张");return;
            	}else if($("input[name='photoscount']").val() <3){
            		alert("环境组图至少要上传3张");return;
            	}else{
            		for (var i = 0; i < $('.shop_addnew_details li').length; i++) {
            			if($("input[name='goodsphoto"+(i+1)+"']").val() == ""){
            				alert("第"+(i+1)+"张商品图为空，请重新上传");
            				return false;
            			}
            		};
            		$('.shop_details1 .shopnextli').eq(1).hide();
	                $('.shop_details1 .shopnextli').eq(2).show();
	                $('.new_shop_top span').eq(2).addClass('show').siblings().removeClass('show');
            	}
            })
            $('.next_step2').click(function(){  //第三个下一步
            	if(($("#choose").val() == "")){
            		alert("翻倍日不能为空");return;
            	}else if($('.slideOne label').position().left==0){
            		if ($("#notpartakegoods").val() == "") {
            			alert("商家不是全场参与，请填写不参与信息");return;
            		}else{
            			$('.shop_details1 .shopnextli').eq(2).hide();
		                $('.shop_details1 .shopnextli').eq(3).show();
		                $('.new_shop_top span').eq(3).addClass('show').siblings().removeClass('show');
            		}
            	}else{
            		$('.shop_details1 .shopnextli').eq(2).hide();
	                $('.shop_details1 .shopnextli').eq(3).show();
	                $('.new_shop_top span').eq(3).addClass('show').siblings().removeClass('show');
            	}
            })
            $('.last_step_pic').click(function(){  //完成
                $('.shop_details1 .shopnextli').eq(1).hide();
                $('.shop_details1 .shopnextli').eq(0).show();
                $('.new_shop_top span').eq(0).addClass('show').siblings().removeClass('show');
            })
            $('.last_step1').click(function(){  //完成
                $('.shop_details1 .shopnextli').eq(2).hide();
                $('.shop_details1 .shopnextli').eq(1).show();
                $('.new_shop_top span').eq(1).addClass('show').siblings().removeClass('show');
            })
            $('.last_step2').click(function(){
                $('.shop_details1 .shopnextli').eq(3).hide();
                $('.shop_details1 .shopnextli').eq(2).show();
                $('.new_shop_top span').eq(2).addClass('show').siblings().removeClass('show');
            })
            // $(".k-btn-previous-year").attr("href","#");
            // $(".k-btn-previous-month").attr("href","#");
            // $(".k-btn-next-year").attr("href","#");
            // $(".k-btn-next-month").attr("href","#");
            var weekdaynum=2,custom=2;
            $('.weekday_set .doubleday_number').eq(0).click(function(){
                if(weekdaynum>0){
                    weekdaynum--;
                    $('.weekday_set .doubleday_number').eq(1).html(weekdaynum);
                }else{
                    weekdaynum=0;
                    $('.weekday_set .doubleday_number').eq(1).html(weekdaynum);
                }
            })
            $('.weekday_set .doubleday_number').eq(2).click(function(){
                if(weekdaynum<7){
                    weekdaynum++;
                    $('.weekday_set .doubleday_number').eq(1).html(weekdaynum);
                }else{
                    weekdaynum=7;
                    $('.weekday_set .doubleday_number').eq(1).html(weekdaynum);
                }
            })
            $('.today_consume .doubleday_number').eq(0).click(function(){
                if(custom>0){
                    custom--;
                    $('.today_consume .doubleday_number').eq(1).html(custom);
                }else{
                    custom=0;
                    $('.today_consume .doubleday_number').eq(1).html(custom);
                }
            })
            $('.today_consume .doubleday_number').eq(2).click(function(){
                if(custom<7){
                    custom++;
                    $('.today_consume .doubleday_number').eq(1).html(custom);
                }else{
                    custom=7;
                    $('.today_consume .doubleday_number').eq(1).html(custom);
                }
            })

            //上传图片后按钮被禁止
            $('#logo_button').click(function(){
            	$('#logo_button').css({'background':'#808080'});
            	$('#logo_button').attr('disabled','disabled');
            })
            $('#bankcard_button').click(function(){
            	$('#bankcard_button').css({'background':'#808080'});
            	$('#bankcard_button').attr('disabled','disabled');
            })
            $('#license_button').click(function(){
            	$('#license_button').css({'background':'#808080'});
            	$('#license_button').attr('disabled','disabled');
            })
            $('#idcardfront_button').click(function(){
            	$('#idcardfront_button').css({'background':'#808080'});
            	$('#idcardfront_button').attr('disabled','disabled');
            })
            $('#idcardback_button').click(function(){
            	$('#idcardback_button').css({'background':'#808080'});
            	$('#idcardback_button').attr('disabled','disabled');
            })
        })
        //显示省份
        showProvince();
        function showProvince() {
            var type='province';
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":'',"type":type},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring;
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            if(list.id == provinceid){
                                areastring += '<option value="' + list.id +'" selected="selected">' + list.name + '</option>';
                            }
                        }
                        $("#province").find("select").html(areastring);
                    }
                }
            });
        }
        //显示城市
        function showCity(id) {
            var parentid = id.value;
            var type='city';
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":parentid,"type":type},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        $("#city").find("select").html('');
                        var areastring = '<option value="">--请选择城市--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list.id +'">' + list.name + '</option>';
                        }
                        $("#city").find("select").html(areastring);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        //显示区县
        function showDistrict(id) {
            var parentid = id.value;

            var isconfirm = '1';
            if(parentid != cityid) {
                isconfirm = confirm("你选择的城市与你当前的城市不一致，确认选择吗？");
            }
            if(isconfirm) {
                var type='district';
                $.ajax({
                    url : '/console/area/get',
                    data:{"parentid":parentid,"type":type},
                    dataType:'json',
                    success:function(data){
                        if(data.status == 'success') {
                            $("#district").find("select").html("");
                            var data = data.data;
                            var areastring = '<option value="">--请选择区县--</option>';
                            for(var i=0; i<data.length; i++) {
                                var list = data[i];
                                areastring += '<option value="' + list.id +'">' + list.name + '</option>';
                            }
                            $("#district").find("select").html(areastring);
                            var shopcityname = $("select[name='shopcityid']").find("option:selected").text();
                            $("input[name='shopcityname']").val(shopcityname);
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
            }
        }
        //显示商圈
        function showBusinessArea(id) {
            var parentid = id.value;
            var type='businessarea';
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":parentid,"type":type},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择商圈--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list.id +'">' + list.name + '</option>';
                        }
                        $("#businessarea").find("select").html(areastring);
                        var shopdistrictname = $("select[name='shopdistrictid']").find("option:selected").text();
                        $("input[name='shopdistrictname']").val(shopdistrictname);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        function selectBusinessArea() {
            var shopbusinessareaname = $("select[name='shopbusinessareaid']").find("option:selected").text();
            if($("select[name='shopbusinessareaid']").find("option:selected").val() == 0){
                shopbusinessareaname = '';
			}
            $("input[name='shopbusinessareaname']").val(shopbusinessareaname);
        }
        //获取二级
        function selectclass(type, id) {
            var parentid = id.value;
            if(type == 'first') {
                 $.ajax({
                    url : '/console/secondclass/get',
                    data:{"firstclassid":parentid},
                    type:'get',
                    dataType:'json',
                    success:function(data){
                        if(data.status == 'success') {
                            var data = data.data;
                            var secondclassstring = '<option value="">--请选择二级分类--</option>';
                            for(var i=0; i<data.length; i++) {
                                var list = data[i];
                                secondclassstring += '<option value="' + list.id +'">' + list.name + '</option>';
                            }
                            $("#secondclass").find("select").html(secondclassstring);
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
                var firstclassname = $("select[name='firstclassid']").find("option:selected").text();
                $("input[name='firstclassname']").val(firstclassname);
            } else if (type == 'second') {
                var secondclassname = $("select[name='secondclassid']").find("option:selected").text();
                $("input[name='secondclassname']").val(secondclassname);
            }
        }
        //获取银行名称
        function getbankname(){
            var bankcard = $("input[name='bankcard']").val();
            if(bankcard == '') {
                alert('银行卡不能为空');return;
            }
            $.ajax({
                url : '/console/bankname/get',
                data:{"bankcard":bankcard},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var bankname = data.data;
                        $("input[name='bankname']").val(bankname);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }

        //选择开户行的省份
        showBankProvince();
        function showBankProvince() {
            $.ajax({
                url : '/console/bank/province',
                data:{},
                dataType:'json',
                type:'get',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择省份--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list +'">' + list + '</option>';
                        }
                        $("#bankprovince").html(areastring);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        function showBankCity(id) {
            var parentname = id.value;
            $.ajax({
                url : '/console/bank/city',
                data:{"provincename":parentname},
                dataType:'json',
                type:'get',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择城市--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list +'">' + list + '</option>';
                        }
                        $("#bankcity").html(areastring);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        //上传图片
        var applyTokenDo = function (func) {
           return func(client);
        };
        var progress = function (p) {
            return function (done) {
	            var bar = document.getElementById('progress-bar');
	            bar.style.width = Math.floor(p * 600) + 'px';
	            bar.innerHTML = Math.floor(p * 100) + '%';
	            done();
	            if(p==1){
                    $('#progress-bar').remove();
                    bar.style.width = 0+'px';
                    bar.innerHTML = 0 + '%';
                }
	        }
        };
        var prog=$('<div id="progress-bar"class="progress-bar"role="progressbar"aria-valuenow="0"aria-valuemin="0"aria-valuemax="100" style="min-width: 1px;width: 0px;background: #9955c6;border-radius: 10px;margin: 10px 100px;padding-left: 10px;">0%</div>');
        // 图片显示
        function setImagePreviews(avalue,inputid,picshow,client,id,ipt,pro) {
            $(pro).prepend(prog);
            var docObj = document.getElementById(inputid);
            var dd = document.getElementById(avalue);
            dd.innerHTML = "";
            var fileList = docObj.files;
            for (var i = 0; i < fileList.length; i++) {
                dd.innerHTML += "<div style='float:left' > <img id='"+ picshow + i + "'  /> </div>";
                var imgObjPreview = document.getElementById(picshow+i); 
                if (docObj.files && docObj.files[i]) {
                    //火狐下，直接设img属性
                    imgObjPreview.style.display = 'block';
                    imgObjPreview.style.width = '150px';
                    imgObjPreview.style.height = '180px';
                    //imgObjPreview.src = docObj.files[0].getAsDataURL();
                    //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
                    imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);
                }
                else {
                    //IE下，使用滤镜
                    docObj.select();
                    var imgSrc = document.selection.createRange().text;
                    alert(imgSrc)
                    var localImagId = document.getElementById(picshow + i);
                    //必须设置初始大小
                    localImagId.style.width = "150px";
                    localImagId.style.height = "180px";
                    //图片异常的捕捉，防止用户修改后缀来伪造图片
                    try {
                        localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                        localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
                    }
                    catch (e) {

                        alert("您上传的图片格式不正确，请重新选择!");
                        return false;
                    }
                    imgObjPreview.style.display = 'none';
                    document.selection.empty();
                }
            }
            var applyTokenDo1 = function (func) {
               return func(client,id,ipt);
            };
            applyTokenDo1(uploadLogo);
            return true;
        }
        //上传图片
        var uploadLogo = function (client,id,ipt) {
            var timestamp = new Date().getTime();
            var filePath= "temp/photos_" + adminUserId + "_" + timestamp; //文件路径：用户id＋时间戳
            var file = document.getElementById(id).files[0];
            var key = filePath;
            console.log('key:'+ key);
            client.multipartUpload(key, file, {
                progress: progress
            }).then(function (res) {
                // console.log('upload success: %j', res);
                // $('#progress-bar').remove();
                $(ipt).val(key);
                // $().img('').attr('src', 'http://file.fbw-china.com/'+filePath);
            });
        };
        //图片显示（批量）
        function setImagePreviewsPhoto(avalue,inputid,picshow,client,id,ipt1,ipt2) {
            var docObj = document.getElementById(inputid);
            var dd = document.getElementById(avalue);
            dd.innerHTML = "";
            var fileList = docObj.files;
            for (var i = 0; i < fileList.length; i++) {            
                dd.innerHTML += "<div style='float:left' > <img id='"+ picshow + i + "'  /> </div>";
                var imgObjPreview = document.getElementById(picshow+i); 
                if (docObj.files && docObj.files[i]) {
                    //火狐下，直接设img属性
                    imgObjPreview.style.display = 'block';
                    imgObjPreview.style.width = '150px';
                    imgObjPreview.style.height = '180px';
                    //imgObjPreview.src = docObj.files[0].getAsDataURL();
                    //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
                    imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);
                }
                else {
                    //IE下，使用滤镜
                    docObj.select();
                    var imgSrc = document.selection.createRange().text;
                    alert(imgSrc)
                    var localImagId = document.getElementById(picshow + i);
                    //必须设置初始大小
                    localImagId.style.width = "150px";
                    localImagId.style.height = "180px";
                    //图片异常的捕捉，防止用户修改后缀来伪造图片
                    try {
                        localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                        localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
                    }
                    catch (e) {

                        alert("您上传的图片格式不正确，请重新选择!");
                        return false;
                    }
                    imgObjPreview.style.display = 'none';
                    document.selection.empty();
                }
            }
            var applyTokenDo1 = function (func) {
               return func(client,id,ipt1,ipt2);
            };
            applyTokenDo1(uploadPhoto);
            return true;
        }
        var progress_all = function (p) {
            return function (done) {
                $('.progress_more').prepend(prog);
                var bar = document.getElementById('progress-bar');
                bar.style.width = Math.floor(p * 600) + 'px';
                bar.style.backgroundColor = '#9955c6';
                bar.innerHTML = Math.floor(p * 100) + '%';
                done();
                if(p==1){
                    // $('#progress-bar').remove();
                    bar.style.width = 0+'px';
                    bar.innerHTML = 0 + '%';
                }
            }
        };
        //批量上传
        var uploadPhoto = function (client,id,ipt1,ipt2,pro) {
            var timestamp = new Date().getTime();
            var filePath= "temp/photos_" + adminUserId + "_" + timestamp; //文件路径：用户id＋时间戳
            var docObj = document.getElementById(id);
            var count=docObj.files;
            for(var i=0; i<count.length; i++) {
                var file = document.getElementById(id).files[i];
                var key = filePath + "_" + i;
                console.log('key:'+ key);
                client.multipartUpload(key, file, {
                    progress: progress_all
                }).then(function (res) {
                    // console.log('upload success: %j', res);
                    $('#progress-bar').remove();
                });
            }
            $(ipt1).val(filePath);
            $(ipt2).val(count.length);
            return true;
        };
        $(document).ready(function(){
        	var num=$('.shop_addnew_details li').length;
            $('.shop_addnew').click(function(){  //新增商品图
                // alert($('.shop_addnew_details').children('li').length)
                if($('.shop_addnew_details').children('li').length<20){
                    num+=1;
                    var li=$('<li><input type="hidden" name="goodsindex" value="'+num+'" /><div class="oh shop_addnew_details_title"><h4 style="font-weight: normal;" class="fz_16 fl">商品'+num+'</h4><span class="fr fz_16 co_red shop_delete">删除</span></div><p><span>商品名称</span><input class="shop_name" type="text" name="goodsname'+num+'" value="" placeholder="15字以内"></p><p><span style="position: relative;top: -70px;">商品介绍</span><textarea name="goodsdescription'+num+'" id="" cols="30" rows="10" placeholder="可不填，100字以内"></textarea></p><div class="form-group jingyzz oh"><label class="fl" style="width: 100px;">商家主图</label><div class="oh fl pic_box_outer" style="margin-left: 0px;"><input type="file"  id="logo'+num+'" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('+"'logoid"+num+"','logo"+num+"','goodsphoto"+num+"',client,'logo"+num+"',"+'"'+"input[name='goodsphoto"+num+"']"+'",'+"'.progress"+num+"'"+'); /><span class="upload_pic fl">+上传商品图</span><div class="fl pictureshow" id="logoid'+num+'"></div></div></div><div class="progress'+num+'"></div><input type="hidden" name="goodsphoto'+num+'" value="" />');
                }else{
                    alert('商品图最多只能加20张')
                }
                $('.shop_addnew_details').append(li);
                $('#logo_button'+num).click(function() {
                    var applyTokenDo1 = function (func) {
                       return func(client,'logo'+num,"input[name='goodsphoto"+num+"']");
                    };
                    applyTokenDo1(uploadLogo);
                });
                $('.shop_delete').click(function(){
                    $(this).parent().parent().remove();
                });
            });
            $('.shop_delete').click(function(){
                $(this).parent().parent().remove();
            });
        })


        //提交数据
        $("#complete").click(function(){
        	if($("#cardholder").val() == ""){
        		alert("持卡人不能为空");return;
        	}else if($("#bankcard").val() == ""){
        		alert("银行账号不能为空");return;
        	}else if($("#bankname").val() == ""){
        		alert("银行名称不能为空");return;
        	}else if($("#opencardbank").val() == ""){
        		alert("开户支行名称不能为空");return;
        	}else if($("#parentname").val() == ""){
        		alert("法人/门店负责人姓名不能为空");return;
        	}else if($("#parentmobile").val().length < 11){
        		alert("请填入正确的手机号(商家登录帐号)");return;
        	}else if($("#idcard").val() == ""){
        		alert("身份证号不能为空");return;
        	}else if($("#cardholder").val() == ""){
        		alert("持卡人不能为空");return;
        	}else if($("#contractendtime").val() == ""){
        		alert("合同签约结束时间不能为空");return;
        	}else if($("#contractstarttime").val()>$("#contractendtime").val()){
            	alert("合同签约结束时间必须大于合同签约开始时间");return;
            }else if($("input[name='bankcardphoto']").val() == ''){
            	alert("银行卡正面照不能为空");return;
            }else if($("input[name='licensephoto']").val() == ''){
            	alert("营业执照不能为空");return;
            }else if($("input[name='idcardfrontphoto']").val() == ''){
            	alert("身份证正面照不能为空");return;
            }else if($("input[name='idcardbackphoto']").val() == ''){
            	alert("身份证反面照不能为空");return;
            }else{
            	var goodsstring='[';
                $('.shop_addnew_details li').each(function() {
                    var goodsindex=$(this).find("input[name='goodsindex']").val();
                    var goodsphoto=$("input[name='goodsphoto"+goodsindex+"']").val();
                    var goodsname = $("input[name='goodsname"+goodsindex+"']").val();
                    var goodsdescription=$("textarea[name='goodsdescription"+goodsindex+"']").val();
                    goodsstring += '{"name":"'+goodsname+'","description":"'+goodsdescription+'","url":"'+goodsphoto+'"}'+',';
                });
                if(goodsstring != '[') {
                    goodsstring=goodsstring.substring(0,goodsstring.length-1);
                }
                goodsstring += ']';
                $("input[name='goods']").val(goodsstring);
                var data = $('#shop_form').serialize();
	            $.ajax({
	                url : '/console/shop/add',
	                type : 'post',
	                data: $('#shop_form').serialize(),
	                dataType:'json',
	                success:function(data){
	                    if(data.status == 'success') {
	                        alert("保存成功")
	                        window.location.href = '/console/shop/list?cityid='+cityid+'&now=' + new Date().getTime();
	                    } else {
	                        alert(data.message);
	                    }
	                },
	                error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
	            });
            }
        });
        //日历
        var doubleday = new Kalendae.Input('choose', {
            months:12,
            mode:'multiple',
            direction:'future'
        });
        function change(){
            $("#choose1").html($("#choose").val());
        }
        $("#choose_time").click(function(){
            $("#choose").focus();
        });
        $("#choose").scrollTop($("#choose1").height());
        var choose1_height = 21;
        // function change(){
        //     var kalendae_top = $(".kalendae").position().top;
        //     $("#choose1").html($("#choose").val());
        //     $("#choose").scrollTop($("#choose1").height());
        //     if(choose1_height == $("#choose1").height()){
        //         $(".kalendae").css("top",kalendae_top);
        //         choose1_height = $("#choose1").height();
        //     }else if(choose1_height < $("#choose1").height()){
        //         kalendae_top = kalendae_top + 21;
        //         $(".kalendae").css("top",kalendae_top);
        //         choose1_height = $("#choose1").height();
        //     }else if(choose1_height > $("#choose1").height()){
        //         kalendae_top = kalendae_top - 21;
        //         $(".kalendae").css("top",kalendae_top);
        //         choose1_height = $("#choose1").height();
        //     };
        // };
    </script>
@endsection